import FrameCreep from '@/rooms/FrameCreep'
import {getDistance} from '@/utils'
export function debug01(creep:Creep):void{
    if (!creep.memory.working) creep.memory.working = false
    if (creep.memory.working && creep.store[RESOURCE_ENERGY] == 0){
        creep.memory.working = false
    }
    if (creep.memory.working == false && creep.store.getFreeCapacity(RESOURCE_ENERGY) == 0){
        creep.memory.working = true
    }
    if (creep.memory.working)
    {
        if (creep.room.controller.level < 8 && !creep.room.memory.TaskMemory.source2_link)
        {
            if (creep.room.controller.level <= 5)
            creep.upgrade_()
            else
            creep.upgrade__()
        }
        else
        {
            if (creep.room.controller.ticksToDowngrade < 190000 || !creep.room.memory.TaskMemory.source2_link)
            {
                creep.upgrade_()
                return
            }
            var source2_link = Game.getObjectById(creep.room.memory.TaskMemory.source2_link as string) as StructureLink
            if (!source2_link) delete creep.room.memory.TaskMemory.source2_link
            creep.transfer_(source2_link,'energy')
        }
    }
    else
    {
        if (!creep.room.memory.TaskMemory) return
        var sources = Game.getObjectById(creep.room.memory.TaskMemory.source2ID as string) as Source
        if (!sources) return
        creep.harvest_(sources)
    }
}
export function pixel01(creep:Creep):void{
    if (Game.shard.name == 'shard2')
    {
        /* 处理任务 */
        if (Game.cpu.bucket >= 10000)
            Game.cpu.generatePixel()
        creep.say("😂",true)
        return
    }
    if (creep.memory.shard != Game.shard.name)
    {
    }
    if (!creep.memory.disRoom)
    {
        var thisTask = creep.room.getMisson("ROOM",'搓pixel')
        if (!thisTask) return
        creep.memory.disRoom = thisTask.disRoom[0]
    }
    if (creep.room.name != creep.memory.disRoom)
    {
        creep.farMoveTo(new RoomPosition(25,25,creep.memory.disRoom),20)
    }
    else
    {
        var portal = creep.pos.findClosestByPath(FIND_STRUCTURES,{filter:(stru)=>{
            return stru.structureType == STRUCTURE_PORTAL
        }})
        if (!portal) return
        creep.moveTo(portal)
    }
}

